﻿<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" MasterPageFile="~/Views/Shared/Main.Master" %>

<asp:Content ContentPlaceHolderID="TitleContent" runat="server">
  Guild Stock - Home
</asp:Content>

<asp:Content ContentPlaceHolderID="MainContent" runat="server">
  <div class="main-menu">
    <% using (Html.BeginForm()) { %>
      Rank for:
      <%: Html.ActionLink("World", "Index", new { r = "" }) %>
       · 
      Realm:
      <%: Html.TextBox("r", null, new { @class = "menu-realm-box" })%>
      <input type="submit" value="Go" />
    <% } %>
	  <script type="text/javascript" >
	    $(function () {
	      $("#r").autocomplete({
	        source: "/Home/GetJsonRealmList"
	      });
	    });
	  </script>
  </div>
  <div class="main-table-title">
    <% var isAllRealms = string.IsNullOrEmpty(this.ViewData["RealmFilter"] as string); %>
    <% if (!isAllRealms) { %>
      <span>Realm: <%: this.ViewData["RealmFilter"].ToString() %></span>
    <% } else { %>
      <span>World Rank</span>
    <% } %>
  </div>
  <div class="add-guild">
	  <% using (Html.BeginForm("AddGuild", "Home", FormMethod.Post, new { style = "margin:0 0 0 0" })) { %>
		  <span>Add guild</span>&nbsp;<%: Html.TextBox("guild", "Eternal Reign")%>
		  <span>realm</span>&nbsp;<%: Html.TextBox("realm", "Lightbringer")%>
		  <input type="submit" value="Add" />
	    <script type="text/javascript" >
	      $(function () {
	        $("#realm").autocomplete({
	          source: "/Home/GetJsonRealmList"
	        });
	      });
	    </script>
    <% } %>
  </div>
  <table class="content-table">
	  <tr class="data-header">
		  <td class="data-number p_left">#</td>
		  <td class="data-sign">Sign</td>
		  <td class="data-name">Name</td>
		  <td class="data-score">Members</td>
		  <td class="data-in">In</td>
		  <td class="data-out">Out</td>
		  <td class="data-updated">Updated</td>
	  </tr>
	  <% foreach(var guild in this.ViewData["GuildsInfo"] as IEnumerable<GuildStock.Models.Guild>) { %>
		  <tr class="data-row">
			  <td class="p_left"><%: guild.Rank %></td>
			  <td>
          <img border="0" width="32" height="32" src="http://www.guildox.com/go/images/achievement_firelands_raid_ragnaros.png" alt="<%: guild.GuildName %>" />
        </td>
			  <td class="<%: guild.Fraction == "A" ? "data-ally" : "data-horde" %>">
          <% string titleText = string.Format("{0} - {1}", guild.GuildName, guild.Fraction == "A" ? "Alliance guild" : "Horde guild"); %>
          <% string labelText = isAllRealms ? string.Format("{1} - {0}", guild.RealmName, guild.GuildName) : guild.GuildName; %>
          <%: Html.ActionLink(labelText, "GuildDetails", new { r = guild.RealmName, g = guild.GuildName }, new { Title = titleText })%>
        </td>
			  <td>
          <%: guild.Score %>
				  <% if(guild.g_Progress != 0) { %>
					  <% if(guild.g_Progress > 0) { %>
						  <img border="0" width="12" height="12" src="/images/up.gif" alt="Up" />
					  <% } else { %>
						  <img border="0" width="12" height="12" src="/images/down.gif" alt="Up" />
					  <% } %>								
          <% } %>
        </td>
			  <td class="c_green"><%: guild.g_In %></td>
			  <td class="c_red"><%: guild.g_Out %></td>
			  <td><%: guild.Updated.ToString("h:mm MM/dd/yyyy") %></td>
		  </tr>
	  <% } %>
  </table>
</asp:Content>
